import axios from 'axios'
const _axios = axios.create({
  baseURL: 'http://geek.itheima.net'
})
_axios.interceptors.request.use(
  config => {
    return config
  },
  err => {
    return Promise.reject(err)
  }
)
_axios.interceptors.response.use(
  res => {
    return res
  },
  err => {
    return Promise.reject(err)
  }
)

function request<T> (obj: any) {
  return _axios<{
    data: T
    message: string
  }>(obj)
}

export default request
